package com.fili.gui.components;

import javax.swing.*;
import java.awt.*;

/**
 * Created by IntelliJ IDEA.
 * User: fili
 * Date: Oct 4, 2006
 * Time: 9:24:49 PM
 * To change this template use File | Settings | File Templates.
 */
public class ActiveCell extends JTextField
{
    private String text;
    private boolean active;

    public ActiveCell()
    {
        this("",false);
    }

    public ActiveCell(String text)
    {
        this(text,true);
    }

    public ActiveCell(String text, boolean active)
    {
        setText(text);
        setActive(active);
        setHorizontalAlignment(CENTER);
        setEditable(false);
    }

    public void setActive(boolean active)
    {
        this.active = active;
        if (active)
        {
            setBackground(Color.green);
            setForeground(Color.blue);
        }
        else
        {
            setBackground(Color.red);
            setForeground(Color.white);
        }
    }
}
